//写一个泛型方法,可以求数组的最大值
class Alg{
    public<T extends Comparable<T>> T func(T[] array){
        T max = array[0] ;
        for (int i = 0; i < array.length; i++) {
            if (array[i].compareTo(max) > 0){
                max = array[i];
            }
        }
        return max;

    }
}
class Message<T> {
    private T message;

    public T getMessage() {
        return message;
    }

    public void setMessage(T message) {
        this.message = message;
    }
}



public class Test {
    public static void func2(Message<?>  temp){
        System.out.println(temp.getMessage());
    }

    public static void main(String[] args) {

        MyArrayList myArrayList = new MyArrayList();
        myArrayList.add(1);
        myArrayList.add(2);
        myArrayList.add(3);
        myArrayList.add(4);
        myArrayList.add(5);
        myArrayList.add(88);
//
//        myArrayList.add(2,100);
////        myArrayList.display();
////        myArrayList.add(-1,100);
//        int ret = myArrayList.get(1);
//        System.out.println(ret);
        //System.out.println(myArrayList.size());


        myArrayList.clear();
        myArrayList.add(1);
        myArrayList.display();
    }
    public static void main2(String[] args) {
        Message<String> message = new Message<>();
        message.setMessage("whw");
        func2(message);

        Message<Integer> message1 = new Message<Integer>();
        message1.setMessage(666);
        func2(message1);
    }
    public static void main1(String[] args) {
        Integer[] array = {1,24,20,33,10};
        Alg alg = new Alg();
        int ret = alg.func(array);
        System.out.println(ret);

    }
}
